package code;

import javax.servlet.annotation.WebListener;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

@WebListener
public class listen implements HttpSessionListener {
    protected static int renshu=0;
    @Override
    public void sessionCreated(HttpSessionEvent se) {
        renshu++;
        se.getSession().getServletContext().setAttribute("renshu",renshu);
        System.out.println("-------------有人上线啦----------------");
    }

    @Override
    public void sessionDestroyed(HttpSessionEvent se) {
        renshu--;
        se.getSession().getServletContext().setAttribute("renshu",renshu);
        System.out.println("-------------有人下线啦----------------");
    }
}
